<?php
session_start();
	include('../controller/functions.php');
	User::connection();

$userArr	= array('admin');
	if(!in_array($_SESSION['user'],$userArr)) {
	User::validSession();

}
if ($_GET['q'] == 'logout') 
{
	User::user_logout();
	print '		
			<script type="text/javascript">		
			window.location = "../login_r.php";
			</script>
			';

}

//query po table tblcms cms  type = home :D
	$queryMakabayan = mysql_query("SELECT * from tblcms tfp WHERE tfp.cmsType = 'home' ORDER BY cmsId DESC ");
	

// $id =$_POST['cmsid'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="../images/fav.ico">
<link rel="icon" type="image/gif" href="../images/fav.ico">
<title>CMS | Home</title>

	<link rel="stylesheet" href="../css/style2.css" type="text/css" charset="utf-8" />
    <link rel="stylesheet" href="../css/front.css" type="text/css" charset="utf-8" />
    	<link type="text/css" href="../css/demo.css" rel="stylesheet" />
        <link rel="stylesheet" href="../css/general.css" type="text/css" charset="utf-8" />
    
</head>
<body>

 <div id="page">
<div id="wrapper">
        
        		   <div class="header_top" id="header_top"> </div>
  </div>
  <div class="header2"></div> 
	<div class="header"><!--open logo -->
		  </div><!--end header -->
	<!-- close logo-->
<!-- hide the client inquiries php-->
    <?php
    echo '<div id="nav">';
    echo '<div class="underlinemenu">';
	include('menu_view.php');
	echo '</div>';
    echo '</div>';
	?>
    <div id="header_in"> <!--open header -->
    <p> </p>
    
    <table width="100%" height="56">
     <tr>
       <td width="317" align="left" class="date"> 
        <? User::oras(); ?>
        </td>
            
       <td width="388" align="right"><? User::showPic(); ?></td>
       <td width="279">&nbsp;&nbsp;<? User::showUser(); ?>        </td>
       </tr>
   </table>
     
  
    </div>
    <div id="ex">
    </div>
    
      <p> </p>
       <div id="body"> <!--open body -->
    
	 <div id="sidebar"> 
        <!-- <div id="chef_ind">open chef -->
        <div id="welcome"> <!--open welcome -->
               <!-- <h2 class="guilded"></h2> -->
        </div> <!--close welcome-->

<? echo '<p class="more">';
echo '';
 
   require('sideBar.php');
    
echo'</p>';
?>
  </div>
        
      <!--</div>close left -->
      
     <div id="content"> 
      <div class="desriptionHeader"> <!--open right-->
      <div id="container">
    
         <div class="post3_students"><h1>Website Management</h1> </div>
      
            <div class="desriptionHeader"> <!--open right-->
       <div class="postbg1"><!--open booking -->
<div align="center" class="mainbox">

	<table width="680" height="74" border="0" align="center" bordercolorlight="#000000" class="tbcms" bgcolor="#ebf9b4">
	<tr class="tbcms">
    	<td colspan="6">
    	  <b>CMS</b><img width="25" height="15" border="0" src="../images/arrow.png"> <a class="siteloc" href="viewHome.php"><b>Home</b></a>
  	  </td>
        </tr>
	<tr>
		<td align="left" colspan="6" class="cat">Home</td>
    </tr>
        <tr>
        	<td width="33" align="center" class="label"><strong>Id</strong></td>
            <td width="140" align="center" class="label"><strong>Title</strong></td>
            <td width="160" align="center" class="label"><strong>Date Created</strong></td>
            <td width="143" align="center" class="label"><strong>Action</strong></td>
     	  <td width="75" align="center" class="label"><strong>Delete</strong></td>
 
        </tr>

<?         
		while($rowMakabyan = mysql_fetch_array($queryMakabayan)):
			
			$cmsid = $rowMakabyan['cmsId'];
			$title 	 = $rowMakabyan['cmsTitle'];
			$content = $rowMakabyan['cmsContent'];
			$date 	 = $rowMakabyan['cmsDate'];
			$createby = $rowMakabyan['cmsEditor'];
			$createid = $rowMakabyan['cmsEditorBy'];
			$type 	  = $rowMakabyan['cmsType'];
			$status = $rowMakabyan['cmsStatus'];
							
		$a++;
		if ($a%2==1)
		{ 
		echo "<tr bgcolor='#e6e4b1'>";
		}
		else
		{
			echo "<tr bgcolor='#b8cd65'>";	
		}	
						
				print '
					
						<td align="center">'.$cmsid.'</td>
						<td align="left"><a title = "Edit" '.$title.' class="postedby" href="editContent.php?type='.$type.'&cmsid='.$cmsid.'">'.$title.'</a></td>
						<td align="center">'.$date.'</td>
			
						';	
					
								if ($status == 'off'):
						
				print '<td align="center"><a class="title" title="Click to Publish" href="changeCms.php?type=1&cmsid='.$cmsid.'">Publish</a></td>
					
					';
						endif;
						if ($status == 'on'):
					
						//if 2 off un ok?
				print '<td align="center"><a class="title"  title="Click to Unpublish" href="changeCms.php?type=2&cmsid='.$cmsid.'">Unpublish</a></td>
					
					';
						endif;
				print '<td align="center"><a class="otherlink" href="cmsDelete.php?cmsid='.$cmsid.'"><img width="15" height="15" border="0" src="../images/unchecked.gif"></td>';

				print '</tr>'; 
		endwhile;
		
		?>
</table>

<table align="center">
	<tr>
    	<td>&nbsp;</td>
    </tr>
	<tr>
       <td align="center"><a class="newtopic" href="createPage.php?type=home"> <input id="bbtn"  type="button" value="Create New Page" name="Create New Page" /></a></td>
	</tr>
</table>
			
</div>
  </div><!--close booking -->
   </div><!--close desc -->
   
          
     				
	  </div><!--close booking -->
   </div><!--close desc -->
    	</div> <!--close right-->
      <div class="clear">&nbsp;</div>
 <!-- footer-->
 <?php 
	  echo '<div id="footer">';
     include('footer_view.php');
      echo '</div>';	
	  ?>

    </div><!-- close body-->
</div><!-- close page-->


</body>
</html>
